<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>A brief introduction for Neo4j | xlaser&#39;s blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="NOSQL| Key-value | Document | Column | Graph || :——-: | :——: | :—-: | :—: ||   Redis   | MongoDB  | HBase  | Neo4j |  Neo4j  Chapter 1.Introduction 图论:是组合数学的一个分支,图是图论的主要研究对象. 图是由若干给定的顶点及连接两顶点的边所构成的图形">
<meta property="og:type" content="article">
<meta property="og:title" content="A brief introduction for Neo4j">
<meta property="og:url" content="http://yoursite.com/2018/09/25/Introduction for Neo4j/index.html">
<meta property="og:site_name" content="xlaser&#39;s blog">
<meta property="og:description" content="NOSQL| Key-value | Document | Column | Graph || :——-: | :——: | :—-: | :—: ||   Redis   | MongoDB  | HBase  | Neo4j |  Neo4j  Chapter 1.Introduction 图论:是组合数学的一个分支,图是图论的主要研究对象. 图是由若干给定的顶点及连接两顶点的边所构成的图形">
<meta property="og:locale" content="default">
<meta property="og:image" content="https://raw.githubusercontent.com/xlasers/avatar-repo/master/neo4j/0925155930.png">
<meta property="og:image" content="https://raw.githubusercontent.com/xlasers/avatar-repo/master/neo4j/0925160414.png">
<meta property="og:image" content="https://raw.githubusercontent.com/xlasers/avatar-repo/master/neo4j/0925162834.png">
<meta property="og:updated_time" content="2018-09-26T11:32:36.030Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="A brief introduction for Neo4j">
<meta name="twitter:description" content="NOSQL| Key-value | Document | Column | Graph || :——-: | :——: | :—-: | :—: ||   Redis   | MongoDB  | HBase  | Neo4j |  Neo4j  Chapter 1.Introduction 图论:是组合数学的一个分支,图是图论的主要研究对象. 图是由若干给定的顶点及连接两顶点的边所构成的图形">
<meta name="twitter:image" content="https://raw.githubusercontent.com/xlasers/avatar-repo/master/neo4j/0925155930.png">
  
    <link rel="alternate" href="/atom.xml" title="xlaser&#39;s blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
</head>

<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="/" id="logo">xlaser&#39;s blog</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="/" id="subtitle">welcome</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="/">Home</a>
        
          <a class="main-nav-link" href="/archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="/atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
        <form action="//google.com/search" method="get" accept-charset="UTF-8" class="search-form"><input type="search" name="q" class="search-form-input" placeholder="Search"><button type="submit" class="search-form-submit">&#xF002;</button><input type="hidden" name="sitesearch" value="http://yoursite.com"></form>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-Introduction for Neo4j" class="article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/2018/09/25/Introduction for Neo4j/" class="article-date">
  <time datetime="2018-09-25T02:55:29.000Z" itemprop="datePublished">2018-09-25</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/neo4j/">neo4j</a>
  </div>

  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      A brief introduction for Neo4j
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <ul>
<li><h3 id="NOSQL"><a href="#NOSQL" class="headerlink" title="NOSQL"></a>NOSQL</h3><p>| Key-value | Document | Column | Graph |<br>| :——-: | :——: | :—-: | :—: |<br>|   Redis   | MongoDB  | HBase  | Neo4j |</p>
</li>
<li><h3 id="Neo4j"><a href="#Neo4j" class="headerlink" title="Neo4j"></a>Neo4j</h3></li>
</ul>
<h4 id="Chapter-1-Introduction"><a href="#Chapter-1-Introduction" class="headerlink" title="Chapter 1.Introduction"></a>Chapter 1.Introduction</h4><ol>
<li><h5 id="图论"><a href="#图论" class="headerlink" title="图论:"></a>图论:</h5><p>是组合数学的一个分支,图是图论的主要研究对象. 图是由若干给定的顶点及连接两顶点的边所构成的图形，这种图形通常用来描述某些事物之间的某种特定关系. 顶点用于代表事物，连接两顶点的边则用于表示两个事物间具有这种关系。</p>
</li>
<li><h5 id="图数据库"><a href="#图数据库" class="headerlink" title="图数据库:"></a>图数据库:</h5><p>以图论为基础,基于图的数据库(Graph database). 图数据库的基本含义是以“图”这种数据结构存储和查询数据，不是存储图片的数据库。图数据库的基本存储单元为：节点、关系、属性。</p>
</li>
<li><h5 id="简单联系"><a href="#简单联系" class="headerlink" title="简单联系:"></a>简单联系:</h5><p>| RDBMS |  GDBMS  | comment  |<br>| :—: | :—–: | :——: |<br>|  表   |   图    | 数据表示 |<br>|  行   |  节点   | 记录表示 |<br>| 列/值 | 属性/值 | 字段表示 |<br>| 约束  |  关系   | 关系展示 |</p>
</li>
<li><h5 id="简单区别"><a href="#简单区别" class="headerlink" title="简单区别:"></a>简单区别:</h5><p>关系型数据库: 查询关系,通过join关联查询,性能消耗 ==&gt; 指数性质</p>
<p>图数据库: 查询关系,通过节点直接进一步关联查询,性能消耗 ==&gt; 线性性质</p>
</li>
<li><h5 id="最后"><a href="#最后" class="headerlink" title="最后:"></a>最后:</h5><p>neo4j:使用java语言编写的,目前最流行的图数据库,图数据库与2017年发展趋势越来越大.</p>
<p><strong>世界占比</strong>:<img src="https://raw.githubusercontent.com/xlasers/avatar-repo/master/neo4j/0925155930.png" alt="Aaron Swartz"></p>
<p><strong>发展趋势</strong>:<img src="https://raw.githubusercontent.com/xlasers/avatar-repo/master/neo4j/0925160414.png" alt="Aaron Swartz"></p>
</li>
</ol>
<h4 id="Chapter-2-Installation"><a href="#Chapter-2-Installation" class="headerlink" title="Chapter 2.Installation"></a>Chapter 2.Installation</h4><ol>
<li><h5 id="windows"><a href="#windows" class="headerlink" title="windows:"></a>windows:</h5><ul>
<li><p>下载对应的zip压缩包解压到文件夹</p>
</li>
<li><p>bin目录下启动批处理脚本</p>
</li>
<li><p>控制台临时启动命令: neo4j.bat console</p>
</li>
<li><p>安装为window服务: </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">bin\neo4j install-service</span><br><span class="line">bin\neo4j start</span><br><span class="line">bin\neo4j stop</span><br><span class="line">bin\neo4j restart</span><br><span class="line">bin\neo4j status</span><br></pre></td></tr></table></figure>
</li>
<li><p>可以配置环境变量,简化neo4j相关命令操作</p>
</li>
<li><p>集成浏览器访问<a href="http://localhost:7474/" target="_blank" rel="noopener">http://localhost:7474/</a></p>
</li>
<li><p>默认初始账号密码:neo4j/neo4j</p>
</li>
<li><p>下载对应的tar文件解压到文件夹</p>
</li>
<li><p>bin目录下启动shell脚本</p>
</li>
<li><p>控制台临时启动命令: neo4j conlse</p>
</li>
<li><p>后台服务启动: ./neo4j start</p>
</li>
<li><p>修改conf配置文件: 端口开放,允许远程主机的访问</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"># With default configuration Neo4j only accepts local connections.</span><br><span class="line"># To accept non-local connections, uncomment this line:</span><br><span class="line">  dbms.connectors.default_listen_address=0.0.0.0</span><br></pre></td></tr></table></figure>
</li>
<li><p>浏览器测试:<img src="https://raw.githubusercontent.com/xlasers/avatar-repo/master/neo4j/0925162834.png" alt="Aaron Swartz"></p>
</li>
</ul>
</li>
<li><h5 id="目录概述"><a href="#目录概述" class="headerlink" title="目录概述:"></a>目录概述:</h5><ul>
<li>bin目录：用于存储Neo4j的可执行程序；</li>
<li>conf目录：用于控制Neo4j启动的配置文件；</li>
<li>data目录：用于存储核心数据库文件；</li>
<li>plugins目录：用于存储Neo4j的插件；</li>
<li>run目录:  记录进程的pid文件</li>
<li>lib目录:  相关jar包</li>
<li>logs目录:  日志目录</li>
</ul>
</li>
</ol>
<ul>
<li><h3 id="cypher"><a href="#cypher" class="headerlink" title="cypher"></a>cypher</h3></li>
</ul>
<h4 id="Chapter-1-Introduction-1"><a href="#Chapter-1-Introduction-1" class="headerlink" title="Chapter 1.Introduction"></a>Chapter 1.Introduction</h4><ol>
<li><h5 id="Cypher"><a href="#Cypher" class="headerlink" title="Cypher:"></a>Cypher:</h5><p>查询语言等价于Oracle数据库查询语言SQL,而Neo4j的查询语言是CQL</p>
</li>
</ol>
<h4 id="Chapter-2-Use"><a href="#Chapter-2-Use" class="headerlink" title="Chapter 2.Use"></a>Chapter 2.Use</h4><ol>
<li><h5 id="概要"><a href="#概要" class="headerlink" title="概要:"></a>概要:</h5><p>|        create        |            match             |    return    |<br>| :——————: | :————————–: | :———-: |<br>| 创建节点，关系和属性 | 检索有关节点，关系和属性数据 | 返回查询结果 |</p>
<p>|         where          |     delete     |        remove        |<br>| :——————–: | :————: | :——————: |<br>| 提供条件来筛选检索数据 | 删除节点和关系 | 删除节点和关系的属性 |</p>
<p>|     set      | …  | functions |<br>| :———-: | :–: | :——-: |<br>| 更新数据信息 | …  |    …    |</p>
</li>
<li><h5 id="例子"><a href="#例子" class="headerlink" title="例子:"></a>例子:</h5><ul>
<li><p><strong>create</strong>: 创建</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">CREATE (</span><br><span class="line">   &lt;node-name&gt;:&lt;label-name&gt;</span><br><span class="line">   &#123; 	</span><br><span class="line">      &lt;Property1-name&gt;:&lt;Property1-Value&gt;</span><br><span class="line">      ........</span><br><span class="line">      &lt;Propertyn-name&gt;:&lt;Propertyn-Value&gt;</span><br><span class="line">   &#125;</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>eg:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">CREATE (dept:Dept &#123; deptNo:002,dName:&quot;大数据部门&quot;,location:&quot;杭州美创&quot; &#125;) </span><br><span class="line">return dept</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>match</strong>: 查询</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">MATCH </span><br><span class="line">(</span><br><span class="line">   &lt;node-name&gt;:&lt;label-name&gt;</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>eg:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MATCH (dept:Dept) return dept</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>set</strong>: 修改</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MATCH (Dept &#123; deptNo:1 &#125;) SET Dept.location = &quot;海蓝金融中心&quot;  RETURN Dept</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>remove</strong>: 移出</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MATCH (Dept &#123; deptNo:2 &#125;) REMOVE Dept.dName RETURN Dept</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>delete</strong>: 删除</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">MATCH (Dept &#123; deptNo:2 &#125;) delete Dept RETURN Dept</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>create</strong> <strong>relation</strong>: <strong>关系</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">CREATE (&lt;node1-details&gt;)-[&lt;relationship-details&gt;]-&gt;(&lt;node2-details&gt;)</span><br></pre></td></tr></table></figure>
<p>eg:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">CREATE (n1:fun4 &#123;name:&quot;哈哈&quot;&#125;)-[r:funny]-&gt;(n2:fun3 &#123;name:&quot;呵呵&quot;&#125;)</span><br><span class="line">return r,n1,n2</span><br></pre></td></tr></table></figure>
</li>
</ul>
</li>
</ol>
<ul>
<li><h4 id="版本区别"><a href="#版本区别" class="headerlink" title="版本区别"></a>版本区别</h4><ol>
<li><h5 id="容量："><a href="#容量：" class="headerlink" title="容量："></a>容量：</h5><p>社区版支持 320 亿个节点,关系以及 640 亿个属性, 企业版没有限制；</p>
</li>
<li><h5 id="并发："><a href="#并发：" class="headerlink" title="并发："></a>并发：</h5><p>社区版不支持集群, 企业版可用集群，解决高并发量的问题；</p>
</li>
<li><h5 id="容灾："><a href="#容灾：" class="headerlink" title="容灾："></a>容灾：</h5><p>由于企业版支持集群,避免单点故障；</p>
</li>
<li><h5 id="热备："><a href="#热备：" class="headerlink" title="热备："></a>热备：</h5><p>社区版只支持冷备份,企业版支持热备, 全量&amp;增量；</p>
</li>
<li><h5 id="性能："><a href="#性能：" class="headerlink" title="性能："></a>性能：</h5><p>社区版最多用到 4 个内核，企业能用到全部内核；</p>
</li>
</ol>
</li>
<li><h4 id="官方"><a href="#官方" class="headerlink" title="官方"></a>官方</h4><ol>
<li><h5 id="neo4j"><a href="#neo4j" class="headerlink" title="neo4j:"></a>neo4j:</h5><p> <a href="https://neo4j.com/" target="_blank" rel="noopener">https://neo4j.com/</a></p>
</li>
<li><h5 id="cypher-1"><a href="#cypher-1" class="headerlink" title="cypher:"></a>cypher:</h5><p> <a href="https://neo4j.com/docs/cypher-refcard/3.0/" target="_blank" rel="noopener">https://neo4j.com/docs/cypher-refcard/3.0/</a></p>
</li>
<li><h5 id="csdn-google"><a href="#csdn-google" class="headerlink" title="csdn, google:"></a>csdn, google:</h5><p>… … …</p>
</li>
</ol>
</li>
</ul>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://yoursite.com/2018/09/25/Introduction for Neo4j/" data-id="cjmj2t5la0000r4hj3ct44vhg" class="article-share-link">Share</a>
      
      
    </footer>
  </div>
  
    
<nav id="article-nav">
  
  
    <a href="/2018/09/25/Spring Data Neo4j/" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">Spring Data Neo4j</div>
    </a>
  
</nav>

  
</article>

</section>
        
          <aside id="sidebar">
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Categories</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/neo4j/">neo4j</a></li></ul>
    </div>
  </div>


  
    

  
    
  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/09/">September 2018</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2018/09/25/Introduction for Neo4j/">A brief introduction for Neo4j</a>
          </li>
        
          <li>
            <a href="/2018/09/25/Spring Data Neo4j/">Spring Data Neo4j</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 Elijah.D<br>
      Powered by <a href="http://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>
    </div>
    <nav id="mobile-nav">
  
    <a href="/" class="mobile-nav-link">Home</a>
  
    <a href="/archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



  </div>
</body>
</html>